<template>
    <div class="wrapper">
        <div class="topWrapper">
            <img class="bg" style="min-height: 130px" src="@/assets/index/bg.png" alt="" />
            <div class="content">
                <div>商户名称：{{ CUSTOMER_NAME }}</div>
                <div>商户编号：{{ CUSTOMER_NO }}</div>
            </div>
        </div>
        <div class="bottomWrapper">
            <van-collapse v-model="activeNames" border accordion @change="open">
                <van-collapse-item :title="item.MON" :value="`￥${item.AMOUNT}`" :name="item.MON" v-for="item in monthList" :key="item.MON">
                    <van-cell-group inset>
                        <div class="row" >
                            <div class="istitle" v-if="dayList.length">
                                <div class="col datacol">日期</div>
                                <div class="col">笔数</div>
                                <div class="col">类型</div>
                                <div class="col">金额</div>
                            </div>
                            <div class="istitle" v-for="item1 in dayList" :key="item1.DAYS">
                                <div class="col datacol">{{item1.DAYS}}</div>
                                <div class="col">{{item1.COUNT}}</div>
                                <div class="col" v-if="item1.TRANS_TYPE == 'POS_CREDIT'">贷记卡</div>
                                <div class="col" v-if="item1.TRANS_TYPE == 'POS_DEBIT'">借记卡</div>
                                <div class="col"  v-if="item1.TRANS_TYPE == 'POS_FLASH' || item1.TRANS_TYPE == 'WXPAY' || item1.TRANS_TYPE == 'ALIPAY' || item1.TRANS_TYPE == 'UNIONPAY'">扫码</div>
                                <div class="col">￥{{item1.AMOUNT}}</div>
                            </div>
                        </div>
                    </van-cell-group>
                </van-collapse-item>
            </van-collapse>
            <empty v-if="!monthList.length"></empty>
        </div>
    </div>
</template>

<script>
import { defineComponent } from 'vue'
import { custDayTrans, custMonthTrans } from '@/api/merchants'

export default defineComponent({
    name: 'deal',
    setup() {
        const route = useRoute()
        const router = useRouter()
        console.log(route.query.CUSTOMER_NAME)
        const state = reactive({
            activeNames: '',
            activeNames1:[],
            CUSTOMER_NAME: route.query.CUSTOMER_NAME,
            CUSTOMER_NO: route.query.CUSTOMER_NO,
            monthList: [],
            dayList: []
        })
        const getCustMonthTrans = () => {
            custMonthTrans({
                customerNo: state.CUSTOMER_NO
            }).then(res => {
                state.monthList = res.object
            })
        }
        getCustMonthTrans()
        const open = e => {
            custDayTrans({
                month: e,
                customerNo: state.CUSTOMER_NO
            }).then(res => {
                state.dayList = res.object
                console.log(state.dayList,'state.dayList');
            })
        }
        return {
            ...toRefs(state),
            open
        }
    }
})
</script>

<style scoped lang="scss">
.wrapper {
    .topWrapper {
        position: relative;      
        padding: 10px;     
        box-sizing: border-box;
        .bg {
            width: 100%;
        }
        .content {
            position: absolute;
            top: 0;
            left: 0;
            padding: 30px;
            height: 100%;
            width: 100%;
            box-sizing: border-box;
            font-size: 14px;
            font-weight: 400;
            line-height: 30px;
            color: #ffffff;
            opacity: 1;
        }
    }
    .bottomWrapper {
        padding: 0 10px;
        box-sizing: border-box;
        position: relative;
        top: -20px;
        .van-collapse {
            border-radius: 10px;
            overflow: hidden;
        }
    }
}

        .istitle{
            width: 100%;
            display: flex;
            align-items: center;
            justify-content: space-between;
            margin-top: 10px;
        }
        .col{
            width: 25%;
            text-align: center;
        }
        .datacol{
            width: 35%; 
        }
       ::v-deep .van-cell-group{
            margin: 0!important;
        }
</style>
